package com.qf.active;


import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.servlet.ModelAndView;

/**
 * @Description: 公用常量
 * @Data: 2022/9/6 13:53
 * @Pacakge: com.qf.active
 * @ClassName: ExceptionMyActive
 * @Author: fan
 */
@ControllerAdvice //表示的所有controller注解的类进行增强 全局异常处理
public class ExceptionMyActive {
    //切面:进行增强操作,只要出现运行时异常就会增强转发处理
    @ExceptionHandler(RuntimeException.class)
    public ModelAndView indexPo(Exception ex){
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("/error/error");
        modelAndView.addObject("messages",ex.toString());
        return modelAndView;
    }
}
